VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "MbrFreeWebSnipeParm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
'
'   Parameter Rule:
'   ---------------
'   It computes the item paramaters in the context of
'   the smart occurrence.
'
'   - Inputs can be provided explicitly, by default they are identical to the inputs of the  family
'   - Outputs defined by name the collection of parameters
'
Option Explicit

Const m_sClassName As String = "MbrFreeWebSnipeParm"
Const m_FamilyProgid As String = ""
Const m_ParameterRuleProgid As String = m_sProjectName + "." + m_sClassName
Const m_ParameterRuleName As String = m_ParameterRuleProgid


Private Const MODULE = "M:\SharedContent\Src\StructDetail\SmartOccurrence\" + CUSTOMERID + "Mbr_EndCutRules\MbrFreeWebSnipeParm.cls"

Implements IJDUserSymbolServices

Public Sub ParameterRuleInputs(pIH As IJDInputsHelper)
  On Error GoTo ErrorHandler

    pIH.SetInput INPUT_BOUNDING
    pIH.SetInput INPUT_BOUNDED
  
  Exit Sub
ErrorHandler:
  Err.Raise LogError(Err, MODULE, "ParameterRuleInputs").Number
End Sub

Public Sub ParameterRuleOutputs(pOH As IJDOutputsHelper)
  On Error GoTo ErrorHandler
    
  pOH.SetOutput "CutDepth"
  pOH.SetOutput "Offset"
  pOH.SetOutput "TopNose"
  pOH.SetOutput "BottomNose"
  pOH.SetOutput "Slope"

  Exit Sub
ErrorHandler:
  Err.Raise LogError(Err, MODULE, "ParameterRuleOutputs").Number
End Sub

Public Sub ParameterRuleLogic(pPRL As IJDParameterLogic)
     On Error GoTo ErrorHandler

     Dim oPortBounded As IJPort
     Set oPortBounded = pPRL.InputObject(INPUT_BOUNDED)
    
    'define the cutting depth as four(4) times the Web Thickness
    Dim dCuttingDepth As Double
    dCuttingDepth = EndCut_GetCutDepth(pPRL)
    pPRL.Add "CutDepth", dCuttingDepth
    
    Dim oBoundedObject As StructDetailObjects.MemberPart
    Set oBoundedObject = New StructDetailObjects.MemberPart
    Set oBoundedObject.object = oPortBounded.Connectable
    
    Dim bTFL As Boolean, bTFR As Boolean, bBFL As Boolean, bBFR As Boolean
    CrossSection_Flanges oBoundedObject.object, bTFL, bBFL, bTFR, bBFR
    
    Dim dOffset As Double
    dOffset = 0.00001
    
    'set the slope value
    Dim dSlope As Double
    ' No requirements specified for now
    dSlope = 0.785398163 '45 degrees
    
    pPRL.Add "Offset", dOffset
    
    Dim dTopNose As Double
    Dim dBtmNose As Double
    
    Dim oBounded As ISPSMemberPartPrismatic
    Dim eBoundedType As Integer
    Dim oConvertingPort As ISPSSplitAxisPort
    Set oConvertingPort = oPortBounded
    Set oBounded = oConvertingPort.Part
    eBoundedType = oBounded.MemberType.Type

    Dim StartPosition As IJDPosition
    Dim EndPosition As IJDPosition
    Dim x1 As Double
    Dim y1 As Double
    Dim z1 As Double
    Dim x2 As Double
    Dim y2 As Double
    Dim z2 As Double

    oBounded.PointAtEnd(SPSMemberAxisStart).GetPoint x1, y1, z1
    Set StartPosition = New DPosition
    StartPosition.Set x1, y1, z1
    oBounded.PointAtEnd(SPSMemberAxisEnd).GetPoint x2, y2, z2
    Set EndPosition = New DPosition
    EndPosition.Set x2, y2, z2
    
    If (bTFL) Or (bTFR) Then
        If eBoundedType = MemberCategoryAndType.LRail Then
            If ((oConvertingPort.PortIndex = SPSMemberAxisStart) And GreaterThan(StartPosition.z, EndPosition.z)) Or _
              ((oConvertingPort.PortIndex = SPSMemberAxisEnd) And GreaterThan(EndPosition.z, StartPosition.z)) Then
                  dTopNose = oBoundedObject.flangeThickness
            Else
                 ' If bottom of the rail, nothing gets selected
                 ' Need not select any item for such case
                   dTopNose = 0.00001
            End If
            
        Else
            dTopNose = oBoundedObject.flangeThickness
        End If
    Else
        dTopNose = 0.00001
    End If
    
    If (bBFL) Or (bBFR) Then
         If eBoundedType = MemberCategoryAndType.LRail Then
            If ((oConvertingPort.PortIndex = SPSMemberAxisStart) And GreaterThan(StartPosition.z, EndPosition.z)) Or _
              ((oConvertingPort.PortIndex = SPSMemberAxisEnd) And GreaterThan(EndPosition.z, StartPosition.z)) Then
                  dBtmNose = 0.5 * (oBoundedObject.WebLength)
            Else
                 ' If bottom of the rail, nothing gets selected
                 ' Need not select any item for such case
                   If bBFR And bTFR Then
                        dBtmNose = oBoundedObject.WebLength - dTopNose - 0.001
                   Else
                        dBtmNose = oBoundedObject.WebLength - dTopNose - 0.001
                   End If
            End If
            
        Else
            dBtmNose = oBoundedObject.flangeThickness
        End If
    Else
         If eBoundedType = MemberCategoryAndType.LRail Then
            If ((oConvertingPort.PortIndex = SPSMemberAxisStart) And GreaterThan(StartPosition.z, EndPosition.z)) Or _
              ((oConvertingPort.PortIndex = SPSMemberAxisEnd) And GreaterThan(EndPosition.z, StartPosition.z)) Then
                  dBtmNose = 0.5 * (oBoundedObject.WebLength)
            Else
                 ' If bottom of the rail, nothing gets selected
                 ' Need not select any item for such case
                   dBtmNose = oBoundedObject.WebLength - dTopNose - 0.001
            End If
            
         Else
            dBtmNose = 0.015
         End If
    End If
   

        If ((oConvertingPort.PortIndex = SPSMemberAxisStart) And GreaterThan(StartPosition.z, EndPosition.z)) Or _
              ((oConvertingPort.PortIndex = SPSMemberAxisEnd) And GreaterThan(EndPosition.z, StartPosition.z)) Then
              dSlope = 0.785398163 '45 degrees
        Else
             ' If bottom of the rail, nothing gets selected
             ' Need not select any item for such case
               dSlope = 1.5708
        End If
                        
    pPRL.Add "Slope", dSlope
    
    pPRL.Add "TopNose", dTopNose
    pPRL.Add "BottomNose", dBtmNose
    
  Exit Sub
ErrorHandler:
  Err.Raise LogError(Err, MODULE, "ParameterRuleLogic").Number
  
End Sub
  
' ** Start CM **
' *******************************************************************************************
' If needed Add Custom Method HERE
' *******************************************************************************************

' ** End CM **
' ********************************************************************************************
'         !!!!! Start Private Code !!!!!
'                 - Following Code Should not be edited
'                 - It exposes the Selector as a regular symbol definition
' ********************************************************************************************
Private Function IJDUserSymbolServices_GetDefinitionName(ByVal definitionParameters As Variant) As String
  IJDUserSymbolServices_GetDefinitionName = m_ParameterRuleName
End Function
Private Sub IJDUserSymbolServices_InitializeSymbolDefinition(pPR As IJDSymbolDefinition)
  On Error Resume Next
  
  ' Remove all existing defined Input and Output (Representations)
  ' before defining the current Inputs and Outputs
  pPR.IJDInputs.RemoveAllInput
  pPR.IJDRepresentations.RemoveAllRepresentation

  Dim pDFact As New DefinitionFactory
  pDFact.InitAbstractParameterRule pPR
  Dim pIH As IJDInputsHelper
  Set pIH = New InputHelper
  pIH.definition = pPR
  pIH.InitAs m_FamilyProgid
  ParameterRuleInputs pIH
  Dim pOH As IJDOutputsHelper
  Set pOH = New OutputHelper
  pOH.Representation = pPR.IJDRepresentations.Item(1)
  pOH.InitAs m_FamilyProgid
  ParameterRuleOutputs pOH
End Sub
Private Function IJDUserSymbolServices_InstanciateDefinition(ByVal CB As String, ByVal DP As Variant, ByVal pRM As Object) As Object
  Dim pDFact As New DefinitionFactory
  Set IJDUserSymbolServices_InstanciateDefinition = pDFact.InstanciateParameterRule(m_ParameterRuleProgid, CB, IJDUserSymbolServices_GetDefinitionName(DP), pRM)
End Function
Private Sub IJDUserSymbolServices_InvokeRepresentation(ByVal pSymbolOccurrence As Object, ByVal pRepName As String, ByVal pOutputColl As Object, arrayOfInputs() As Variant)
End Sub
Private Function IJDUserSymbolServices_EditOccurence(pSymbolOccurrence As Object, ByVal pTransactionMgr As Object) As Boolean
End Function
Public Sub CMParameterRule(pRep As IJDRepresentation)
  Dim pPRL As IJDParameterLogic
  Set pPRL = New ParameterLogic
  pPRL.Representation = pRep
  ParameterRuleLogic pPRL
End Sub
' ********************************************************************************************
'         !!!!! End Private Code !!!!!
' ********************************************************************************************








